# 1.打开文件
fw = open("/opt/dc.txt", mode="w")
# 2.写数据
fw.write("hello world\n")
fw.write("you are my baby girl~\n")
# 3.关闭资源
fw.close()



# writelines([.....])
fw1 = open("/opt/tc.txt", mode="w")
fw1.writelines(    ["zhangsan\n", "lisi\n", "wangwu\n"]   )
fw1.close()